package cn.qm.service;

import cn.qm.dao.PrescriptionDetailMapper;
import cn.qm.pojo.PrescriptionDetail;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
* Created by shang-pc on 2018/5/15.
*/
@RestController
public class PrescriptionDetailClient {
    @Resource
    private PrescriptionDetailMapper detailMapper;
    @RequestMapping(value = "/getPrescriptionDetailById", method = RequestMethod.POST)
    public PrescriptionDetail getPrescriptionDetailById(@RequestParam Long id) throws Exception {
        return detailMapper.getPrescriptionDetailById(id);
    }

    @RequestMapping(value = "/getPrescriptionDetailListByMap", method = RequestMethod.POST)
    public List<PrescriptionDetail> getPrescriptionDetailListByMap(@RequestBody Map<String, Object> param) throws Exception {
        return detailMapper.getPrescriptionDetailListByMap(param);
    }

    @RequestMapping(value = "/getPrescriptionDetailCountByMap", method = RequestMethod.POST)
    public Integer getPrescriptionDetailCountByMap(@RequestBody Map<String, Object> param) throws Exception {
        return detailMapper.getPrescriptionDetailCountByMap(param);
    }

    @RequestMapping(value = "/qmtxAddPrescriptionDetail", method = RequestMethod.POST)
    public Integer qmtxAddPrescriptionDetail(@RequestBody PrescriptionDetail prescriptionDetail) throws Exception {
        prescriptionDetail.setCreatedTime(new Date());
        return detailMapper.insertPrescriptionDetail(prescriptionDetail);
    }

    @RequestMapping(value = "/qmtxModifyPrescriptionDetail", method = RequestMethod.POST)
    public Integer qmtxModifyPrescriptionDetail(@RequestBody PrescriptionDetail prescriptionDetail) throws Exception {
        prescriptionDetail.setUpdatedTime(new Date());
        return detailMapper.updatePrescriptionDetail(prescriptionDetail);
    }

    @RequestMapping(value = "/qmtxDeletePrescriptionDetailById", method = RequestMethod.POST)
    public Integer qmtxDeletePrescriptionDetailById(@RequestParam Long id) throws Exception {
        return detailMapper.deletePrescriptionDetailById(id);
    }

    @RequestMapping(value = "/queryPrescriptionDetailPageByMap", method = RequestMethod.POST)
    public Page<PrescriptionDetail> queryPrescriptionDetailPageByMap(@RequestBody Map<String, Object> param, Integer pageNo, Integer pageSize) throws Exception {
        return null;
    }
}
